package domain;

public class Debt {

	private int id = -1;
	private double amount;
	private String comment;
	private Person source;
	private Person owedTo;
	private String date;
	private boolean done;
	private String dateDone;

	public Debt() {
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public Person getSource() {
		return source;
	}

	public void setSource(Person source) {
		this.source = source;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Person getOwedTo() {
		return owedTo;
	}

	public void setOwedTo(Person owedTo) {
		this.owedTo = owedTo;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		if (this.id == -1) {
			this.id = id;
		}
	}
	
	public void setDone(boolean done) {
		this.done = done;
	}
	
	public boolean isDone() {
		return this.done;
	}
	
	public void setDateDone(String dateDone) {
		this.dateDone = dateDone;
	}
	
	public String getDateDone() {
		return this.dateDone;
	}

	public boolean equals(Object o) {
		if (o == null || !(o instanceof Debt))
			return false;
		Debt d = (Debt) o;
		if (d.getId() == this.getId() && d.getAmount() == this.getAmount()
				&& d.getComment() == this.getComment()
				&& d.getDate() == this.getDate()
				&& d.getOwedTo() == this.getOwedTo()
				&& d.getSource() == this.getSource()) {
			return true;
		}
		return false;
	}
	
	public boolean equalsTest(Object o) {
		if (o == null || !(o instanceof Debt))
			return false;
		Debt d = (Debt) o;
		if (d.getAmount() == this.getAmount()
				&& d.getComment() == this.getComment()
				&& d.getDate() == this.getDate()
				&& d.getOwedTo() == this.getOwedTo()
				&& d.getSource() == this.getSource()) {
			if ((d.getId() != this.getId()) && (d.getId() == -1 || this.getId() == -1)) {
				return true;
			}
		}
		return false;
	}
}
